<template>
  <div>
    <el-card class="box-card">
      <h1 style="margin-bottom: 5px">tensorflow网上实验平台</h1>
      <i>ver 0.1</i>
      <div style="float:none;height: 15px"></div>
      <el-form ref="form" :model="userLoginData" label-width="80px">
        <el-form-item label="用户ID">
          <el-input v-model="userLoginData.id"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input type="password" v-model="userLoginData.pwd"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="userLogin">登录</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import qs from "qs"
import axios from "axios"
export default {
  name: "Login",
  data(){
    return {
      userLoginData:{
        id:"",
        pwd:""
      }
    }
  },
  methods:{
    userLogin(){
      var _this=this
      var data=this.$data.userLoginData;
      if(data.id==""||data.pwd==""){
        alert("账号或密码不能为空")
        return;
      }
      axios.post("http://192.168.31.103:2444/LoginCenter/login",qs.stringify(data)).then(function(res){
        console.log(res);
        if(res.data=="-1"){
          alert("账号或密码错误，请重新输入")
        }
        else{
          _this.$router.push({path:"/main"})
        }
      });
    }
  }
}
</script>

<style>
.box-card{
  width: 600px;
  position: absolute;
  left: 50%;
  top:15%;
  margin-left: -300px;
}
</style>
